package tablefactory;

import factory.Item;
import factory.Tray;

import java.util.Iterator;
import java.util.List;

public class TableTray extends Tray {



    public TableTray(String caption){
        super(caption);
    }

    @Override
    public String makeHTML() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("<td>");
        stringBuilder.append("<table border=\"1\">");

        stringBuilder.append("<tr><td bgcolor=\"#cccccc\">");
        stringBuilder.append(caption);
        stringBuilder.append("</td></tr>");

        stringBuilder.append("<tr style=\"\">");
        Iterator<Item> itemIterator = this.itemList.iterator();
        while (itemIterator.hasNext()) {
            Item item = itemIterator.next();
            stringBuilder.append(item.makeHTML());
        }
        stringBuilder.append("</tr>");

        stringBuilder.append("</table>");
        stringBuilder.append("</td>");
        return stringBuilder.toString();
    }
}
